package com.smf.lsc.rest.crypt.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.smf.lsc.rest.crypt.filter.RestCryptFilter;

/**
 * @author ln
 * config
 */
@Configuration
@ConditionalOnProperty(prefix="lsc.restCrypt",name = "enable", havingValue = "true")
public class RestCryptConfiguration extends WebMvcConfigurerAdapter{
	@Bean
    public RestCryptFilter riskFilter() {
        return new RestCryptFilter();
    }
    
    @Bean
    public FilterRegistrationBean testFilterRegistration() {
 
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(riskFilter());
        registration.addUrlPatterns("/*");
        /*registration.addInitParameter("paramName", "paramValue");*/
        registration.setName("RestCryptFilter");
        registration.setOrder(1);
        
        return registration;
    }
    
   
}